<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:insert="~{include :: header('资讯信息列表')}" />
    <th:block th:insert="~{include :: bootstrap-table-css}" />
</head>
<body class="hold-transition">
<!-- Site wrapper -->
<div class="container-fluid mb-2">
    <div class="toolbar" id="toolbar" role="group">
        <form id="formId">
            <div class="form-inline">
                <a class="btn btn-success mr-1" onclick="$.modal.openTab('添加资讯', '/article/add.html', 'article-add');" shiro:hasPermission="article:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <input type="text" class="form-control mr-1" name="title" placeholder="请输入标题...">
                <button type="button" class="btn btn-primary mr-1" onclick="$.table.search()">
                    <i class="fa fa-search"></i>
                    搜索
                </button>
                <button type="button" class="btn btn-default" onclick="$.form.reset()">
                    <i class="fa fa-refresh"></i>
                    重置
                </button>
            </div>
        </form>
    </div>
    <table id="bootstrap-table" class="table-striped"></table>
</div>

<th:block th:insert="~{include :: footer}" />
<th:block th:insert="~{include :: bootstrap-table-js}" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('article:edit')}]];
    var removeFlag = [[${@permission.hasPermi('article:remove')}]];
    var prefix = "/article";

    $(function() {
        var options = {
            url: prefix + "/list.json",
            createUrl: prefix + "/add.html",
            updateUrl: prefix + "/edit.html?id={id}",
            removeUrl: prefix + "/remove.json",
            modalName: "资讯",
            columns: [
                {
                    field: 'articleId',
                    title: 'id',
                    align: 'center'
                },
                {
                    field: 'title',
                    title: '标题'
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    align: 'center'
                },
                {
                    field: 'viewCount',
                    title: '点击量',
                    align: 'center'
                },
                {
                    title: '操作',
                    align: 'center',
                    width: 200,
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editTab(\'' + row.articleId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.articleId + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="getComment('+ row.articleId + ","+1+ ')"><i class="fa fa-thumbs-up"></i>评论</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    //打开评论窗口
    function getComment(id,typeId) {
        layer.open({
            type: 2,
            area: ['90%', '95%'],
            fix: false,
            maxmin: true,
            shade: 0.3,
            title: "评论列表",
            content: "/comment/info/list.html?otherId=" + id + "&typeId=" + typeId
        });
    }
</script>
</body>
</html>